#ifndef QCONFIGTOOLS_H
#define QCONFIGTOOLS_H

#include <QObject>
#include <QSettings>
#include <QCoreApplication>
#include <QDebug>
#include <QFile>
#include <QDir>
#include <QJsonDocument>
#include <QJsonArray>
#include <QJsonObject>

class QConfigTools : public QObject
{
    Q_OBJECT
public:
    explicit QConfigTools(QObject *parent = nullptr);
    ~QConfigTools();

    QString port() const;
    void setPort(const QString &port);

    QString ip() const;
    void setIp(const QString &ip);

    QString Maxnumber() const;
    void setMaxnumber(const QString &Maxnumber);

    QString Minnumber() const;
    void setMinnumber(const QString &Minnumber);

    QString working() const;
    void setWorking(const QString &working);

    QString product() const;
    void setProduct(const QString &product);

    void ScriptInit(void);
    void SaveConfig(void);
    QString GetMessage();
    QStringList WorkingList() const;
    void setWorkingList(const QStringList &WorkingList);

    QStringList ProductList() const;
    void setProductList(const QStringList &ProductList);

    QString ProNumber() const;
    void setProNumber(const QString &ProNumber);

    QString ShowPage() const;

signals:

private:
    QString m_product = "defproduct";
    QString m_working = "VT";
    QString m_Minnumber = "0";
    QString m_Maxnumber = "1";
    QString m_ip = "127.0.0.1";
    QString m_port = "8899";
    QString m_ProNumber = "1";
    QString m_ShowPage = "0";
    QSettings* m_setting;
    QString m_section = "AppConfig";
    QStringList m_ProductList = {};
    QStringList m_WorkingList = {};

    // 属性初始化
    void ContentsInit(void);

    // Json文件初始化
    QString m_JsonFile = "config.json";
    QString m_ProductName = "Product";
    QString m_WorkingName = "Working";
    void JsonPropertyInit(void);
    void SaveJsonFile(void);
    void LoadingJsonFile(void);
};

#endif // QCONFIGTOOLS_H
